﻿using System;
using System.Web.UI.WebControls;
using TPG.SharePoint.Workflow;

namespace $rootnamespace$
{
    public class $safeitemname$
    {
        protected override void OnLoad(EventArgs e)
        {
            if(IsInitialLoad)
            {
                string dataString = GetAssociationData();
                // initialize from serialized association data
            }
            base.OnLoad(e);
        }

        protected void OkButton_Click(object sender, EventArgs e)
        {
            /*
             * The InitiationData class is added as a sample and can
             * be customized to fit your solution. You can also use
             * the same class used by the association form.
             * */
            InitiationData data = new InitiationData(); 
            data.MyField = MyInitiationDataField.Text;
            string dataString = WorkflowDataSerializer.SerializeToXmlString<InitiationData>(data);
            CommitInstantiation(dataString);
        }

        protected void CancelButton_Click(object sender, EventArgs e)
        {
            CancelInstantiation();
        }

        public class InstantiationData
        {
            public string MyField{ get; set;}
        }
    }
}